<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Promise基本用法</title>
	</head>
	<body>
		<script>
			//const fs = require('fs');
			
			const p = new Promise(function(resolve,reject) {
				setTimeout(() => {
					// let data = '读取数据库中的数据成功';
					// resolve(data);
					let err = '读取数据库中的数据失败';
					reject(err);
				},1000);
			});
			
			p.then(function(val) {
				console.log(val);
			},function(reason){
				console.error(reason);
			});
			
			// fs.readFile('./es6.html',(err,data) => {
			// 	if(err) throw err;
			// 	console.log(data);
			// });
		</script>
	</body>
</html>